package org.osll.tictactoe.transport;

import org.osll.tictactoe.ServerConnection;
import org.osll.tictactoe.transport.tcp.client.ServerConnectionImpl;
import org.osll.tictactoe.transport.tcp.server.LoginServer;

public class ConnectionFactory {

	public enum Type {
		TCP,
		UDP,
		RMI,
		CORBA
	}
	
	private static ConnectionFactory instance=null;
	
	private ConnectionFactory() {
	}
	
	public static ConnectionFactory getInstance() {
		if(instance == null) {
			instance = new ConnectionFactory();
		}
		return instance;
	}
	
	
	public ServerConnection getConnection(Type type) {
		ServerConnection r = null;
		switch (type) {
		case TCP:
			r = new ServerConnectionImpl(DefaultOptions.getInstance().getHost(),
										 DefaultOptions.getInstance().getTcpPort());
			break;
		case UDP:
			r = new org.osll.tictactoe.transport.udp.client.ServerConnectionImpl();
			break;
		case RMI:
		    r = new org.osll.tictactoe.transport.rmi.client.ServerConnectionImpl();
			break;
		case CORBA:
			r = new org.osll.tictactoe.transport.corba.client.ServerConnectionImpl();
		default:
			break;
		}
		return r;
	}
}
